using System.Diagnostics;
using System.Runtime.CompilerServices;
using UnityEngine;

namespace DanMuHelper.Logging
{
    /// <summary>
    /// 富文本仅针对Info级别的日志, 隐含Rich选项
    /// </summary>
    public static class RichLog
    {
        [Conditional("UNITY_EDITOR"), Conditional("DEVELOPMENT_BUILD")]
        public static void LogInfo(this Color color, object message,
            [CallerFilePath] string callerFilePath = "", [CallerMemberName] string callerMemberName = "")
        {
            Echo.WriteRich(Echo.EchoType.Info, "#" + ColorUtility.ToHtmlStringRGB(color), message, callerFilePath,
                callerMemberName);
        }

        [Conditional("UNITY_EDITOR"), Conditional("DEVELOPMENT_BUILD")]
        public static void LogInfoInContext(this Color color, Object context, object message,
            [CallerFilePath] string callerFilePath = "", [CallerMemberName] string callerMemberName = "")
        {
            Echo.WriteRichInContext(Echo.EchoType.Info, "#" + ColorUtility.ToHtmlStringRGB(color), context, message,
                callerFilePath,
                callerMemberName);
        }

        [Conditional("UNITY_EDITOR"), Conditional("DEVELOPMENT_BUILD")]
        public static void LogInfoFormat(this Color color, string format, params object[] args)
        {
            Echo.WriteRich(Echo.EchoType.Info, "#" + ColorUtility.ToHtmlStringRGB(color), string.Format(format, args));
        }

        [Conditional("UNITY_EDITOR"), Conditional("DEVELOPMENT_BUILD")]
        public static void LogInfoFormatInContext(this Color color, Object context, string format, params object[] args)
        {
            Echo.WriteRichInContext(Echo.EchoType.Info, "#" + ColorUtility.ToHtmlStringRGB(color), context,
                string.Format(format, args));
        }
    }
}